package cn.iocoder.yudao.module.peizhen.dal.mysql.buiessorder;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.peizhen.controller.admin.buiessorder.vo.BuiessOrderPageReqVO;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.buiessorder.BuiessOrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.peizhen.controller.app.buiessorder.vo.*;

/**
 * 订单 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BuiessOrderMapper extends BaseMapperX<BuiessOrderDO> {

    default PageResult<BuiessOrderDO> selectPage(AppBuiessOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BuiessOrderDO>()
                .eqIfPresent(BuiessOrderDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BuiessOrderDO::getStaffId, reqVO.getStaffId())
                .eqIfPresent(BuiessOrderDO::getNo, reqVO.getNo())
                .likeIfPresent(BuiessOrderDO::getPaitentName, reqVO.getPaitentName())
                .eqIfPresent(BuiessOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BuiessOrderDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(BuiessOrderDO::getRefundPrice, reqVO.getRefundPrice())
                .betweenIfPresent(BuiessOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BuiessOrderDO::getId));
    }


    default int updateByNo(BuiessOrderDO updateObj,Long no){
        return update(updateObj, new LambdaQueryWrapperX<BuiessOrderDO>()
                .eq(BuiessOrderDO::getNo, no).eq(BuiessOrderDO::getPayStatus, 0));
    }


    default PageResult<BuiessOrderDO> selectPage(BuiessOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BuiessOrderDO>()
                .eqIfPresent(BuiessOrderDO::getNo, reqVO.getNo())
                .likeIfPresent(BuiessOrderDO::getPaitentName, reqVO.getPaitentName())
                .eqIfPresent(BuiessOrderDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BuiessOrderDO::getPayStatus, reqVO.getPayStatus())
                .eqIfPresent(BuiessOrderDO::getRefundPrice, reqVO.getRefundPrice())
                .betweenIfPresent(BuiessOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BuiessOrderDO::getCreateTime));
    }

}